package com.atguigu.mapreduce.reducejoin;

import com.atguigu.mapreduce.wordcount.WordCountDriver;
import com.atguigu.mapreduce.wordcount.WordCountMapper;
import com.atguigu.mapreduce.wordcount.WordCountReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class ReduceJoinDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        // 配置对象
        Configuration configuration = new Configuration();
        // 创建job
        Job job = Job.getInstance(configuration);
        // 指定驱动类
        job.setJarByClass(ReduceJoinDriver.class);
        // 指定mapper、reducer
        job.setMapperClass(ReduceJoinMapper.class);
        job.setReducerClass(ReduceJoinReducer.class);
        // mapper阶段输出的key value类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(OrderPd.class);
        // reducer阶段输出的key value类型
        job.setOutputKeyClass(OrderPd.class);
        job.setOutputValueClass(NullWritable.class);
        // 输入目录
        FileInputFormat.addInputPath(job, new Path("C:\\major\\SGG大数据线下全套资料2025\\05.尚硅谷大数据技术之Hadoop\\02.资料\\07_测试数据\\reducejoin"));
        FileOutputFormat.setOutputPath(job, new Path("C:\\major\\SGG大数据线下全套资料2025\\05.尚硅谷大数据技术之Hadoop\\02.资料\\07_测试数据\\out"));
        // 提交job
        job.waitForCompletion(true);
    }
}
